#include<bits/stdc++.h>
using namespace std;
const int maxn = 1006;
typedef array<int, 2> ai;
int n, m, par[maxn][maxn];
char grid[maxn][maxn];
ai A, B;

const int di[] = {1, 0, -1, 0};
const int dj[] = {0, -1, 0, 1};
const string dc = "DLUR";

bool valid(int i, int j) {
  return !(i<0 || j<0 || i>n || j>m || grid[i][j]=='#');
}

void solve() {
  for(int i=0; i<n; ++i)
    for(int j=0; j<m; ++j) {
      if(grid[i][j]=='A')A={i, j};
      if(grid[i][j]=='B') {
        B = {i, j};grid[i][j]='.';
      }
    }
  queue<ai> q;
  q.push(A);
  par[A[0]][A[1]] = -1;
  while(q.size()) {
    auto [i, j] = q.front();q.pop();
    if(B == ai{i, j}) {
      cout << "YES\n";
      string ans;
      int k = par[i][j];
      while(k!=-1) {
        i -= di[k], j-= dj[k];
        ans += dc[k];
        k = par[i][j];
      }
      reverse(ans.begin(), ans.end());
      cout<<ans.size()<<'\n'<<ans<<'\n';
      return;
    }
    for(int k=0; k<4; ++k) {
      auto ni = i+di[k], nj=j+dj[k];
      if(valid(ni, nj)) {
        grid[ni][nj] = grid[i][j];
        if (grid[ni][nj] == 'A') par[ni][nj] = k;
        q.push({ni, nj});
      }
    }
  }
  cout<<"NO\n";
  return;
}

int main() {
  cin>>n>>m;
  for(int i=0; i<n; ++i)
    for(int j=0; j<m; ++j) cin>>grid[i][j];
  solve();
  return 0;
}